import request from '@/utils/request'

export function getRoleList(params) {
  return request({
    url: '/system/role/list',
    method: 'get',
    params
  })
}

export function getRoleDetail(id) {
  return request({
    url: `/system/role/${id}`,
    method: 'get'
  })
}

export function createRole(data) {
  return request({
    url: '/system/role',
    method: 'post',
    data
  })
}

export function updateRole(data) {
  return request({
    url: `/system/role/${data.id}`,
    method: 'put',
    data
  })
}

export function deleteRole(id) {
  return request({
    url: `/system/role/${id}`,
    method: 'delete'
  })
}

export function updateRoleStatus(id, status) {
  return request({
    url: `/system/role/${id}/status`,
    method: 'put',
    data: { status }
  })
}

export function getRolePermissions(id) {
  return request({
    url: `/system/role/${id}/permissions`,
    method: 'get'
  })
}

export function updateRolePermissions(id, permissions) {
  return request({
    url: `/system/role/${id}/permissions`,
    method: 'put',
    data: { permissions }
  })
}